import Cookies from 'js-cookie'
import { aesStr, unAesStr } from './encryptutil';

const auth = "admin_token";

/**
 * 获取token
 * @returns 
 */
export const get_token = () => {
    let token = Cookies.get(auth);
    if (!token) {
        return '';
    }
    return unAesStr(token);
}

/**
 * 设置token
 * @param token 
 * @returns 
 */
export const set_token = (token: string) => {
    return Cookies.set(auth, aesStr(token));
}

/**
 * 移除token
 * @returns 
 */
export const remove_token = () => {
    return Cookies.remove(auth);
}